/**
 * @file featureListColumns.js
 * @author
 */

import React from 'react';
import { Link } from 'dva/router';
import utils from '../investmentAnalysis/utils';

const columns = [
  {
    title: '用户',
    dataIndex: 'trader',
    key: 'trader',
    sorter: true,
    width: 120,
  },
];

export default function getColumns(featuresMapping) {
  const cols = [...columns];
  featuresMapping.map((item) => {
    const fieldName = utils.toCamelCase(item.columnName);
    if (item.weight >= 1) {
      cols.push({
        title: item.showName,
        dataIndex: fieldName,
        render: text => (text ? text.toFixed(2) : 0),
        sorter: true,
        orderIndex: item.orderIndex,
      });
    }
  });

  cols.sort((a, b) => {
    return (a.orderIndex - a.orderIndex);
  });

  return cols;
}
